package com.huawei.M01.iterator;

public class ReverseList {
    public void reverseWords(char[] s) {
        for (int i = 0; i < s.length; i++) {
            int start = i;
            while (s[i] != ' ') {
                i++;
            }
            int end = i - 1;
            while (start != end) {
                char temp = s[start];
                s[start] = s[end];
                s[end] = temp;
                start++;
                end--;
            }
        }
        int left = 0;
        int right = s.length - 1;
        while (left != right) {
            char temp = s[left];
            s[left] = s[right];
            s[right] = temp;
            left++;
            right--;
        }
    }
}
